home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
batch
/
askit11.zip
/
ASKIT11.DOC
< prev
next >
Wrap
Text File
|
1992-02-07
|
9KB
|
249 lines
Program: ASKit
Package: Part of the S3 Batch File Utility Set
Version: 1.1
Date: February 7, 1992
Author: George Spafford
Purpose:
To return a DOS errorlevel that can be easily interpreted by the DOS
batch language commands based on a user's keyed response.
Procedure:
ASK.EXE needs to be either in a path or in the directory (dir) with
the batch menu being run. Example:
@echo off
cls
echo 1. Run Lotus
echo 2. Run dBase
echo 3. run WordPerfect
echo .
echo Exit to quit to DOS.
echo .
echo Please enter your choice and then press ENTER:
:REPLY
ASK
Okay, one Line at a time:
@echo off
This turns the DOS echo off. And the @symbol (DOS 4.0 & newer)
means that a user will not even see that command. If you
exclude this, a user will see each line of your menu before it is
processed. If you get a bad command or file name error on this
line, then your version of DOS does not support the @ symbol,
simply omit the @ and use ECHO OFF
cls
This clears the screen in DOS from top to bottom.
echo .
This gives us a line with just a period on it. An even better
way of getting a line that is simply a space is to type in ECHO
push the space bar and then, hold down the ALT key and press
2 5 5 on the extended numeric keypad (the number keys on the right
if you have an 101 Key keyboard). Also, the editor you are using
must support this method of entry for extended ascii characters.
Some don't, some do. Those that do include DOS's EDLIN and EDIT from
DOS 5.0. If you just type in the command ECHO, it will tell you the'
status of the echo flag in DOS.
echo 1. Run Lotus
This line and the two that follow it are just displaying the menu
for the user to pick from. You can get fancier if you so desire.
echo EXIT to quit to DOS
Huh???? EXIT is more than one letter!? Well, I got fed up with
the small programs that allow you to interactively work with batch
files. I am not knocking them, but I do occasionally have the need
for multiple key stroke entry. This answer is defined in the
ASKTABLE.DAT file. We will cover this in a bit.
Echo .
Again, this is just for spacing.
Echo Please enter your choice and then press ENTER:
Okay, this looks like a question but it is really just a message
for the user to enter a key. This line by itself does nothing.
A word of caution, when you want a user to press ENTER or another
particular key, you might want to use capital letters to get their
attention. If you use any special characters on the batch line, DOS
may interpret them as commands and signal an error.
ASK
Okay, here's the heart of our menu program & here is where the fun
starts. Trust me guys, I'm a sadist.
ASK.EXE has only two command line options and neither is regularly used.
ASK D will turn on debug mode and display on the screen the errorlevel of
the response that you enter. Handy if you don't have any ASCII charts around.
The other command line options is the ? which brings up the help screens.
Now, if you base your menuing system around single letter entries, the program
will return the decimal code of the UPPER-case version of the letter. For
example, A or a is returned as 65 and Z or z is returned as 90. The program
will do any required case-conversions automatically.
If you do not plan on having multiple letter entries, then you can skip this
next section.
TABLES:
To handle multi-key inputting, ASKit relies on a previously defined table file
that contains the response and the error level that should be returned when the
message is entered. This file's name is ASKTABLE.DAT and it should be in the
active dir with the menu files.
Sample ASKTABLE.DAT: (must be left justified & only have spaces between the
response and the errorlevel).
YES 89
NO 78
LOTUS 76
PCS 80
Quit 71
P 50
Q 50
R 50
S 130
If YES is typed then an errorlevel of 89 is returned and so forth. The table
file also allows the user the ability to remap key codes. Say that you need
to have several menu entries that in fact do the same thing. Instead of having
an errorlevel check for each entry, you can remap the keys and point them all in
that direction. If you do use the table, remember that single-key entries will
still be passed by ASKit regardless of whether they are in the table or not.
I have a question for you, do you want to have spaces in your words? If the
interest exists, I can change the field delimiter from a space to the vertical
pipe ("|"). This would allow multiple word answers. As it stands now, the
table response entries can not contain spaces since the space separates the
entries from their respective errorlevel codes. If you think the change is
worthwhile, please let me know as it is a very easy change to make.
Using the above table, let's create a sophisticated menu: (any echo statements
by themselves have the ALT 2 5 5 character following them.)
@echo off
:MAINMENU
cls
echo Bobs Menu
echo
echo Command Operation
echo ---------- ----------------------------------
echo LOTUS Lotus 123 v2.3
echo PCS PC Support
echo R Start PCS with minimal functions.
echo
echo S Shell to DOS
echo Quit Exit to DOS
goto MAINREPLY
:MAINREPLY
ASK.EXE
If errorlevel 130 goto SHELLOUT
if errorlevel 80 goto STARTPCS
if errorlevel 76 goto STARTLOTUS
if errorlevel 71 goto FINISH
:SHELLOUT
Command.com
goto MAINMENU
:STARTPCS
call STARTPCS.BAT
goto MAINMENU
:STARTLOTUS
cd\123
lotus
cd\
goto MAINMENU
:FINISH
<<<<<< END ... DO NOT TYPE THIS >>>>
Notice that the "IF ERRORLEVEL" statements are in descending order. This is
very important if your menu is to work correctly. Always have it in descending
order.
Next, see the :NAME places at the top of each module? This is called a "LABEL"
and it is used to identify a block of code. You can then use GOTO statements
to run that LABEL. The GOTO, by the way, serves as a means for use to jump
from block to block. Notice how each block ends with GOTO MAINMENU. This
insures that the menu will restart.
HISTORY:
v1.1 02/06/92
Improved the dir process a tad. You can just put in D: or
D: and a partial file spec like c:\dos\att and D will look
for C:\DOS\ATT*.* now. Like I said, just a few trivial
additions.
v1.0 12/09/92
Initial Release.
Please Register Me:
This package is a little different from some utility packages that are on the
market today. If you only like one or two programs, the individual programs
can be registered for $5 per concurrently used copy. The bargain (in my
eyes) is that the whole package is only $20. It is up to you whether or not
you want the entire package or only specific files. If this package, or one
of the utilities aids you, you should register your copy. For example, say you
want DCMAP & DCUPDAY, then you need only send $10. But please, if you use this
software, register it.
Sincerely,
George Spafford
3001 LakeShore Drive, #329
St. Joseph, MI 49085
Data: (616) 468-5026 Queued Access BBS 14.4Kb USR Dual HST
FIDOnet: 1:2340/0 NEC/NC Site
Sysop: Tim Akright
600+ MB Online
NOTE: D IS A PART OF THE DIRECTORY CONTROL PACKAGE. THE FOLLOWING NOTICE
PERTAINS TO IT AS WELL.
DIRECTORY CONTROL AND ALL OF ITS COMPONENT FILES ARE DISTRIBUTED AS IS.
THE AUTHOR (GEORGE SPAFFORD) MAKES NO WARRANTY OF ANY KIND, EXPRESSED OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THIS SOFTWARE AND
DOCUMENTATION. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DAMAGES,
INCLUDING LOST PROFITS, LOST SAVINGS, OR ANY OTHER INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF OR THE INABILITY TO USE
THIS PROGRAM.
-------------------------------------------------------------------------